//登录
const login = () =>
	import('@/views/login/index')

//主页面
const main = () =>
	import('@/views/main/index')

/*
 * 商品模块
 */

const good_list = () =>
	import('@/views/good/list/index')
const good_list_addGood = () =>
	import('@/views/good/list/add-good')
const good_appointment = () =>
	import('@/views/good/oppointment/index')

/*
* 网站信息
*/

const website_activity = () =>
	import('@/views/website/activity/index')

/**
 * 设置模块
 * 
 */
const setting_account = () =>
	import('@/views/setting/account/index')
// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
	path: '/login',
	meta: {
		title: '登录',
	},
	name: 'login',
	component: login
};

export const loginRouterRedirect = {
	path: '/',
	redirect: {
		name: 'login'
	}
};

//非菜单路由 
export const otherRouetr = [{
	path: '/',
	name: 'otherRouter',
	component: main,
	children: [{
			name: 'good_list_addGood',
			path: 'good/list/add-good',
			component: good_list_addGood,
			meta: {
				title: ''
			},
			beforeEnter: (to, from, next) => {
				if(to.query && to.query.id) {
					to.meta.title = '编辑商品'
				} else {
					to.meta.title = '添加商品'
				}

				next()
			}
		}
	]
}]

//***********主页面展示路由*************
export const appRouter = [
	{
		icon: "iconfont icon-shop",
		name: '商品',
		path: '/good',
		component: main,
		children: [{
				name: 'good_list',
				path: 'list',
				component: good_list,
				meta: {
					title: '商品列表'
				}
			},
			{
				name: 'good_appointmentc',
				path: 'appointment',
				component: good_appointment,
				meta: {
					title: '预约列表'
				}
			}
		]
	},
	{
		icon: "iconfont icon-user",
		name: '联系',
		path: '/website',
		component: main,
		children: [{
				name: 'website_activity',
				path: 'activity',
				component: website_activity,
				meta: {
					title: '活动信息'
				}
			}
		]
	},
	{
		icon: "iconfont icon-user",
		name: '设置',
		path: '/setting',
		component: main,
		children: [{
				name: 'setting_account',
				path: 'account',
				component: setting_account,
				meta: {
					title: '账号管理'
				}
			}
		]
	},
]
// 路由输出
export const routers = [
	loginRouter,
	loginRouterRedirect,
	...appRouter,
	...otherRouetr
];